/**
 *
 * $Id: editor_plugin_src.js 539 2008-01-14 19:08:58Z spocke $
 *
 * @author Moxiecode
 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
 */

(function() {
	tinymce.create('tinymce.plugins.cpGadgetPlugin', {
		init : function(ed, url) {
			this.editor = ed;

			function isGadgetElm(n) {
				return $(n).attr('title') == 'cpGadget';
			};
			
			// Register commands
			ed.addCommand('cpGadget', function() {
				
				ed.windowManager.open({
					file : url + '/gadget.php',
					width : 900,
					height : 500,
					inline : 1
				}, {
					plugin_url : url
				});
				
			});

			// Register buttons
			ed.addButton('gadget', {
				title : 'Insérer/modifier un gadget',
				cmd : 'cpGadget',
				image : url + '/img/icone.png'
			});
			
			ed.onNodeChange.add(function(ed, cm, n, co) {
				cm.setActive('gadget', n.nodeName == 'IMG' && isGadgetElm(n));
			});
			
			ed.onInit.add(function() {
				if (ed.settings.content_css !== false)
					ed.dom.loadCSS(url + "/css/content.css");
			});
			
		},

		getInfo : function() {
			return {
				longname : 'Gadgets pour Clicpage',
				author : 'Clicpage',
				authorurl : 'http://www.clicpage.net',
				infourl : 'http://www.clicpage.net',
				version : '1.0'
			};
		}
	});

	// Register plugin
	tinymce.PluginManager.add('cpGadget', tinymce.plugins.cpGadgetPlugin);
})();